package com.lhy.admin.common.secure.authorization;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Component
public class PermissionLogicalOrStrategy extends AbstractPermissionLogicalStrategy {

    @Override
    protected boolean doAuthorization(List<String> sessionPermissions, List<String> currentRequestPermissions, HttpServletRequest request) {
        return currentRequestPermissions.stream()
                .anyMatch(sessionPermissions::contains);
    }

    @Override
    public String logicalName() {
        return Logical.OR.name();
    }
}
